<template>
  <div class="defooter">
    <van-action-bar>
      <van-action-bar-icon icon="chat-o" text="客服" color="#ee0a24" />
      <van-action-bar-icon icon="cart-o" text="购物车" />
      <van-action-bar-icon icon="star" text="已收藏" color="#ff5000" />
      <van-action-bar-button type="warning" text="加入购物车" @click="addCart" />
      <van-action-bar-button type="danger" text="立即购买" />
    </van-action-bar>
  </div>
</template>

<script>
import { addCartlist } from '@/apis/cart';
import { showToast } from 'vant';
export default {
  data() {
    return {
      userid: '',
      proid: '',
      num: 1
    }
  },
  methods: {
    addCart() {
      addCartlist({ userid: this.userid, proid: this.proid, num: this.num }).then(res => {
        console.log(res);
        if(res.data.code!=200){
          return showToast("加入购物车失败")
        }else{
          showToast("加入购物车成功")
          
        }
      })
    }
  },
  created() {
    this.userid = localStorage.getItem("userid")
    this.proid = this.$route.params.proid
  }
}
</script>

<style lang="less" scoped></style>